package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.StrategyCommend;
import cn.wolfcode.luowowo.article.mapper.StrategyCommendMapper;
import cn.wolfcode.luowowo.article.mapper.StrategyContentMapper;
import cn.wolfcode.luowowo.article.query.StrategyCommendQuery;
import cn.wolfcode.luowowo.article.service.IStrategyCommendService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class StrategyCommendServiceImpl implements IStrategyCommendService {
   @Autowired
   private StrategyCommendMapper strategyCommendMapper;
    @Override
    public void deleteByPrimaryKey(Long id) {
        strategyCommendMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insert(StrategyCommend record) {
        strategyCommendMapper.insert(record);
    }

    @Override
    public StrategyCommend selectByPrimaryKey(Long id) {
        StrategyCommend strategyCommend = strategyCommendMapper.selectByPrimaryKey(id);
        return strategyCommend;
    }

    @Override
    public List<StrategyCommend> selectAll() {
        List<StrategyCommend> strategyCommends = strategyCommendMapper.selectAll();
        return strategyCommends;
    }

    @Override
    public void updateByPrimaryKey(StrategyCommend record) {
        strategyCommendMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo query(StrategyCommendQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        return new PageInfo(strategyCommendMapper.selectForList(qo));
    }

    @Override
    public List<StrategyCommend> getCommendTop5() {
        List<StrategyCommend> commends = strategyCommendMapper.getCommendTop5();
        return commends;
    }
}
